const constant = require("../../util/constant.js");
const util = require('../../util/util.js');
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        starCount: 0,
        forksCount: 0,
        visitTotal: 0,
        zdname:'',
        username:''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var myuid=wx.getStorageSync('userid');
        var mymame=wx.getStorageSync('uname');
        var myzd=wx.getStorageSync('udept');
            //console.log(myuid);
        let that = this;
        that.setData({
            zdname:myzd,
            username:mymame
        })

        wx.request({
            url: constant.host+'/appserv/getjznum.ashx',
            data: {
              uid: myuid,
              k: constant.wkey
            },
            success: function (data) {
              var dat = data.data;
              //console.log(dat);
              setTimeout(function () {
                  that.setData({
                    starCount: dat.endjz,
                    forksCount: dat.ingjz,
                    visitTotal: dat.alljz
                  })
                }, 20)
            }
          });

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    },
    doexit() {
        wx.showModal({
          title: '提示',
          content: '您确定要退出当前账号吗？',
          success: function (ress) {
            if (ress.confirm) {
              wx.clearStorage();
              setTimeout(function(){
                wx.showToast({
                  title: '退出成功',
                }),
                500
              })
              wx.redirectTo({
                url: '/pages/login/index',
              })
            }
            else if (ress.cancel) {
            }
          }
        })
      }
})